	LIST	P=16F877A
	RADIX	HEX
	INCLUDE	<P16F877A.INC>

loops	equ	0x0D
loops2	equ	0x0E
conta	equ	0x0C

reset	ORG	0x00
	goto	inicio

	ORG	0x05

retardo	movlw	D'100'
	movwf	loops

top2	movlw	D'110'
	movwf	loops2

top	nop
	nop
	nop
	nop
	nop
	nop
	decfsz	loops2
	goto	top
	decfsz	loops
	goto 	top2
	retlw	0

inicio	bsf	STATUS,RP0
        bcf     STATUS,RP1
	movlw	0x00
	movwf	TRISD
	movlw	0xFF
	movwf	TRISB
	bcf	STATUS,RP0
	clrf	conta

ciclo	movf	conta,W
	movwf	PORTD
	call	retardo

pulsa	btfss	PORTB,0
	goto	pulsa
	call 	retardo
	btfss	PORTB,0
	goto	pulsa
	incf	conta
	movf	conta,W
	xorlw	0x0A
	btfsc	STATUS,Z
	goto	inicio
	goto	ciclo

        END